import { createSlice } from '@reduxjs/toolkit'

const counterStore = createSlice({
  // 模块名称独一无二
  name: 'counter',
  // 初始数据
  initialState: {
    count: 0
  },
  // 修改数据的同步方法
  reducers: {
		increment: (state) => {
      state.count ++
    },
    decrement: (state) => {
      state.count --
    },
    incrementNum: (state, action) => {
      state.count += action.payload
    }
  }
})
// 导出actionCreate函数
export const { increment, decrement, incrementNum } = counterStore.actions
// 导出reducer
export default counterStore.reducer